/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('autodriveclouddata', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model OpenapiSaveTaskStatusRequest {
  taskId?: long(name='taskId'),
}

model OpenapiSaveTaskStatusResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  data?: any(name='data'),
  stackTraces?: string(name='stackTraces'),
  success?: boolean(name='success'),
}

model OpenapiSaveTaskStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenapiSaveTaskStatusResponseBody(name='body'),
}

async function openapiSaveTaskStatus(request: OpenapiSaveTaskStatusRequest): OpenapiSaveTaskStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return openapiSaveTaskStatusWithOptions(request, headers, runtime);
}

async function openapiSaveTaskStatusWithOptions(request: OpenapiSaveTaskStatusRequest, headers: map[string]string, runtime: Util.RuntimeOptions): OpenapiSaveTaskStatusResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'OpenapiSaveTaskStatus',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/autoDrive/openapi/saveTaskStatus`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model OpenapiSemantemeSearchRequest {
  semanteme?: string(name='semanteme'),
  tenantCode?: string(name='tenantCode'),
  topN?: int32(name='topN'),
  workspaceCode?: string(name='workspaceCode'),
}

model OpenapiSemantemeSearchResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  data?: any(name='data'),
  stackTraces?: string(name='stackTraces'),
  success?: boolean(name='success'),
}

model OpenapiSemantemeSearchResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenapiSemantemeSearchResponseBody(name='body'),
}

async function openapiSemantemeSearch(request: OpenapiSemantemeSearchRequest): OpenapiSemantemeSearchResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return openapiSemantemeSearchWithOptions(request, headers, runtime);
}

async function openapiSemantemeSearchWithOptions(request: OpenapiSemantemeSearchRequest, headers: map[string]string, runtime: Util.RuntimeOptions): OpenapiSemantemeSearchResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.semanteme)) {
    body['semanteme'] = request.semanteme;
  }
  if (!Util.isUnset(request.tenantCode)) {
    body['tenantCode'] = request.tenantCode;
  }
  if (!Util.isUnset(request.topN)) {
    body['topN'] = request.topN;
  }
  if (!Util.isUnset(request.workspaceCode)) {
    body['workspaceCode'] = request.workspaceCode;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'OpenapiSemantemeSearch',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/autoDrive/openapi/semantemeSearch`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model OpenapiSemantemeSearchSaveRequest {
  path?: string(name='path'),
  semanteme?: string(name='semanteme'),
  sourceOss?: {
    accessId?: string(name='accessId'),
    accessKey?: string(name='accessKey'),
    bucket?: string(name='bucket'),
    endpoint?: string(name='endpoint'),
  }(name='sourceOss'),
  tenantCode?: string(name='tenantCode'),
  topN?: int32(name='topN'),
  workspaceCode?: string(name='workspaceCode'),
}

model OpenapiSemantemeSearchSaveResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  data?: any(name='data'),
  stackTraces?: string(name='stackTraces'),
  success?: boolean(name='success'),
}

model OpenapiSemantemeSearchSaveResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenapiSemantemeSearchSaveResponseBody(name='body'),
}

async function openapiSemantemeSearchSave(request: OpenapiSemantemeSearchSaveRequest): OpenapiSemantemeSearchSaveResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return openapiSemantemeSearchSaveWithOptions(request, headers, runtime);
}

async function openapiSemantemeSearchSaveWithOptions(request: OpenapiSemantemeSearchSaveRequest, headers: map[string]string, runtime: Util.RuntimeOptions): OpenapiSemantemeSearchSaveResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.path)) {
    body['path'] = request.path;
  }
  if (!Util.isUnset(request.semanteme)) {
    body['semanteme'] = request.semanteme;
  }
  if (!Util.isUnset(request.sourceOss)) {
    body['sourceOss'] = request.sourceOss;
  }
  if (!Util.isUnset(request.tenantCode)) {
    body['tenantCode'] = request.tenantCode;
  }
  if (!Util.isUnset(request.topN)) {
    body['topN'] = request.topN;
  }
  if (!Util.isUnset(request.workspaceCode)) {
    body['workspaceCode'] = request.workspaceCode;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'OpenapiSemantemeSearchSave',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/autoDrive/openapi/semantemeSearchSave`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

